package com.puppet.building.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.puppet.building.pojo.Building;
import com.puppet.building.pojo.MyPageData;
import com.puppet.building.pojo.Owner;
import com.puppet.building.pojo.Result;
import com.puppet.building.service.BuildingService;
import com.puppet.building.service.OwnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/owner")
public class OwnerController {

    @Autowired
    private OwnerService ownerService;

    @GetMapping
public Result<?> getOwners() {
        //1.开启分页
        List<Owner> allOwner = ownerService.getAllOwner();
        return Result.ok(allOwner);
    }

    @PostMapping("/addNewOwner")
    public Result<?> addNewOwner(@RequestBody Owner owner){
        return Result.ok(ownerService.addNewOwner(owner));
    }

@PostMapping("/{id}")
    public Result<?> getAllOwnerById(@PathVariable Integer id){
        return Result.ok(ownerService.getAllOwnerById(id));
}

@PutMapping("/updateOwner")
    public Result<?> updateOwner(@RequestBody Owner owner){
        return Result.ok(ownerService.updateOwner(owner));
}
@GetMapping("/getOwnerNameAnId")
    public Result<?>getOwnerNameAnId(){
        return Result.ok(ownerService.getOwnerNameAnId());
}

}


